﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="NewRequest.aspx.cs" Inherits="MarketPayReim.NewRequest" %>

<%@ Register Src="../ProcessControl/UserInfo_TY.ascx" TagName="UserInfo" TagPrefix="ui" %>
<%@ Register Src="../ProcessControl/ApprovalHistory_TY.ascx" TagName="ApprovalHistory"
    TagPrefix="ah" %>
<%@ Register Src="../ProcessControl/Attachments_TY.ascx" TagName="Attachments" TagPrefix="attach" %>
<%@ Register Src="../ProcessControl/ButtonList_TY.ascx" TagName="ButtonList" TagPrefix="btn" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>销售类采购资金支付及发票报销</title>
    <script src="../../js/jquery.js" type="text/javascript"></script>
    <script type="text/javascript" src="../../js/My97DatePicker/WdatePicker.js"></script>
    <script type="text/javascript" src="../../js/common.js"></script>
    <script type="text/javascript" language="javascript">

        //删除当前行
        function deletetS(rows) {

            $(rows).parent().parent().find("[id*=fld_CONTARTNO]").attr("class", ".");
            $(rows).parent().parent().find("[id*=fld_SUPPLIER]").attr("class", ".");
            $(rows).parent().parent().find("[id*=fld_CONTENT]").attr("class", ".");
            $(rows).parent().parent().find("[id*=fld_CONTRACTCAPTITAL]").attr("class", ".");
            $(rows).parent().parent().find("[id*=fld_CONTRACTQTY]").attr("class", ".");
            $(rows).parent().parent().find("[id*=fld_SUPPLIERQTY]").attr("class", ".");
            $(rows).parent().parent().find("[id*=fld_YKPJE]").attr("class", ".");
            $(rows).parent().parent().find("[id*=fld_AMOUNT]").attr("class", ".");
            $(rows).parent().parent().find("[id*=fld_REQUIRED]").attr("class", ".");
            $(rows).parent().parent().find("[id*=fld_PAYTIME]").attr("class", ".");

        }

        //审批类型切换
        function check(ID) {
            if (ID == 'rdoMoney') {
                $("#DivMoney").css("display", "");
                $("#DivContract").css("display", "none");
                $("#fld_TABLETYPE").val("资金支付类");
                // $("#fld_CENTERCAPTITAL").val("");
            }
            else if (ID == 'rdoRemiber') {
                $("#DivMoney").css("display", "none");
                $("#DivContract").css("display", "");
                $("#fld_TABLETYPE").val("发票报销类");
                //  $("#fld_CENTERINVOICE").val("");
            }
        }

        //支付类金额累加及转大写
        function ChangePay() {
            var sum = 0
            $("#mytable").find("tr:gt(0)").each(function (i, Etr) {
                sum += $(Etr).find("td").eq(9).find("input").val() - 0;
            });
            $("#lblPay").text(sum);
            $("#fld_PAY").val(sum);
            $("#lblPayUpper").text(ChangeRMBToCH(sum.toString()));
            $("#fld_PAYUPPER").val(ChangeRMBToCH(sum.toString()));
        }

        //发票类金额转大写
        function ChangeInvoice() {
            var invoice = $("#fld_INVOICECAPTITAL").val();
            $("#fld_INVOICEUPPER").val(ChangeRMBToCH(invoice));
            $("#lbINVOICEUPPER").text($("#fld_INVOICEUPPER").val());
        }

        //调用选择人员方法
        jQuery(document).ready(function () {
            jQuery("");

            //我的申请替换页面类型
            if (request("Type") == "myrequest") {
                $("#rdoType").css("display", "none");
                $("#divType").css("display", "block");
            }

            $("#fld_RELATEPERSON").keydown(function (event) {
                return false;
            });
            if ($("#fld_TABLETYPE").val() == "发票报销类") {
                document.getElementById("rdoRemibur").checked = "checked";
                $("#DivMoney").css("display", "none");
                $("#DivContract").css("display", "");
                $("#fld_TABLETYPE").val("发票报销类");
                // $("#fld_CENTERINVOICE").val("");
                $("#lbINVOICEUPPER").text($("#fld_INVOICEUPPER").val());
            }
            else {
                $("#DivMoney").css("display", "");
                $("#DivContract").css("display", "none");
                $("#fld_TABLETYPE").val("资金支付类");
                //$("#fld_CENTERCAPTITAL").val("");
                ChangePay();
            }
        })
        //定义多行弹出页面方法
        function Tests(ert) {
            val = window.showModalDialog("../../Modules/Portal/FromEbs.aspx", null, "dialogWidth=850px;dialogHeight=500px");
            if (val) {
                var obj = eval('(' + val + ')');
                if (obj) {
                    $(ert).parent().parent().find("[id*=fld_CONTARTNO]").val(obj.htbh);
                    $(ert).parent().parent().find("[id*=fld_SUPPLIER]").val(obj.gysmc);
                    $(ert).parent().parent().find("[id*=fld_CONTENT]").val(obj.note);
                    $(ert).parent().parent().find("[id*=fld_CONTRACTCAPTITAL]").val(obj.htje);
                    $(ert).parent().parent().find("[id*=fld_CONTRACTQTY]").val(obj.htsl);
                    $(ert).parent().parent().find("[id*=fld_SUPPLIERQTY]").val(obj.rksl);
                    $(ert).parent().parent().find("[id*=fld_YKPJE]").val(obj.ykpje);
                    $(ert).parent().parent().find("[id*=fld_AMOUNT]").val(obj.yfje);
                }
            }
        }
        //校验本次付款金额+已付款金额是否大于合同金额
        function Find(ert) {
            var htje = parseFloat($(ert).parent().parent().find("[id*=fld_CONTRACTCAPTITAL]").val());
            var yfje = parseFloat($(ert).parent().parent().find("[id*=fld_AMOUNT]").val());
            var bcfkje = parseFloat($(ert).parent().parent().find("[id*=fld_REQUIRED]").val());
            if (htje < yfje + bcfkje) {
                alert("已付金额加本次需要金额必须小于等于合同金额");
                $(ert).parent().parent().find("[id*=fld_REQUIRED]").val("");
            }
        }
    </script>
    <script type="text/javascript" language="javascript">
        window.onload = function () {
            document.getElementById("fld_YHKH").onkeyup = function () {
                this.value = this.value.replace(/\s/g, '').replace(/(\d{4})(?=\d)/g, "$1 "); ;
            };
        }; </script>
</head>
<body>
    <form id="form1" runat="server">
    <div class="container">
        <div class="row">
            <ui:userinfo id="UserInfo1" processprefix="MPR" processtitle="销售类采购资金支付及发票报销" runat="server"
                tablename="PROC_MARKETPAYREIM" tablenamedetail="PROC_MARKETPAYREIM_DETAIL"></ui:userinfo>
        </div>
        <div class="row">
            <table class="table table-condensed table-bordered">
                <thead class="table table-condensed table-bordered">
                    <tr>
                        <td class="td-label">
                            表单类别<span class="red">*</span>
                        </td>
                        <td class="td-content" colspan="3">
                            <div id="rdoType">
                                <span onclick="check('rdoMoney')">
                                    <asp:RadioButton ID="rdoMoney" runat="server" GroupName="rdos" Checked="true" Text="资金支付类" /></span>
                                <span onclick="check('rdoRemiber')">
                                    <asp:RadioButton ID="rdoRemibur" runat="server" GroupName="rdos" Text="发票报销类" /></span>
                            </div>
                            <div id="divType" style="display: none;">
                                <asp:TextBox ID="fld_TABLETYPE" Text="" runat="server"></asp:TextBox>
                            </div>
                        </td>
                    </tr>
                </thead>
                <tbody id="DivMoney" class="table table-condensed table-bordered">
                    <tr>
                        <td class="banner" colspan="4">
                            资金支付类
                        </td>
                    </tr>
                    <tr>
                        <td class="td-label">
                            是否在预算内：<span class="red">*</span>
                        </td>
                        <td class="td-content">
                            <asp:DropDownList ID="fld_BUDGET" runat="server" CssClass="validate[required]">
                                <asp:ListItem Value="">--请选择--</asp:ListItem>
                                <asp:ListItem Value="是">是</asp:ListItem>
                                <asp:ListItem Value="否">否</asp:ListItem>
                            </asp:DropDownList>
                        </td>
                        <td class="td-label">
                            选择中心审批：<span class="red">*</span>
                        </td>
                        <td class="td-content">
                            <asp:DropDownList ID="fld_CENTERCAPTITAL" runat="server" CssClass="validate[required]">
                                <asp:ListItem Value="">--请选择--</asp:ListItem>
                                <asp:ListItem Value="工程中心">工程中心</asp:ListItem>
                                <asp:ListItem Value="服务中心">服务中心</asp:ListItem>
                                <asp:ListItem Value="咨询中心">咨询中心</asp:ListItem>
                                <asp:ListItem Value="国际服务部">国际服务部</asp:ListItem>
                                <asp:ListItem Value="软件中心">软件中心</asp:ListItem>
                                <asp:ListItem Value="技术中心">技术中心</asp:ListItem>
                            </asp:DropDownList>
                        </td>
                    </tr>
                    <tr>
                        <td class="td-label">
                            付款金额：
                        </td>
                        <td class="td-content">
                            <asp:Label ID="lblPay" runat="server" Text=""></asp:Label>
                            <asp:TextBox ID="fld_PAY" runat="server" Style="display: none"></asp:TextBox>
                        </td>
                        <td class="td-label">
                            付款金额大写：
                        </td>
                        <td class="td-content">
                            <asp:Label ID="lblPayUpper" runat="server" Text=""></asp:Label>
                            <asp:TextBox ID="fld_PAYUPPER" runat="server" Style="display: none"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td class="td-label">
                            开户行：<span class="red">*</span>
                        </td>
                        <td class="td-content">
                            <asp:TextBox ID="fld_KHH" runat="server" class="validate[required]"></asp:TextBox>
                        </td>
                        <td class="td-label">
                            银行卡号：<span class="red">*</span>
                        </td>
                        <td class="td-content">
                            <asp:TextBox ID="fld_YHKH" runat="server" class="validate[required]"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td class="td-label">
                            付款信息：
                        </td>
                        <td class="td-content" colspan="3">
                            <asp:TextBox ID="fld_PAYINFO" runat="server"></asp:TextBox>
                        </td>
                        <%--                        <td class="td-label">
                            销售合同号：<span class="red">*</span>
                        </td>
                        <td class="td-content">
                            <asp:TextBox ID="fld_MARKETCONTRACTNO" runat="server" CssClass="validate[required]"></asp:TextBox>
                        </td>--%>
                    </tr>
                    <tr>
                        <td class="td-label">
                            选择相关人员：
                        </td>
                        <td class="td-content" colspan="3">
                            <asp:TextBox ID="fld_RELATEPERSON" runat="server" Width="80%"></asp:TextBox>
                            <asp:TextBox runat="server" ID="var_RELATE" Style="display: none;"></asp:TextBox>
                            <%--<asp:Button ID="btnChoose" runat="server" CssClass="btn" Text="选择" OnClientClick="selectUser(1,'fld_RELATEPERSON','var_RELATE')" />--%>
                            <input type="button" onclick="selectUser(2,'fld_RELATEPERSON','var_RELATE')" value="选择"
                                class="btn" />
                        </td>
                    </tr>
                    <tr>
                        <td colspan="11">
                            <table id="mytable" class="table table-condensed table-bordered tablerequired" tablerequired="tablerequired">
                                <tr>
                                    <th>
                                        关联合同
                                    </th>
                                    <th>
                                        合同编号
                                    </th>
                                    <th>
                                        供应商名称
                                    </th>
                                    <th>
                                        内容
                                    </th>
                                    <th>
                                        合同金额
                                    </th>
                                    <th>
                                        合同数量
                                    </th>
                                    <th>
                                        入库数量
                                    </th>
                                    <th>
                                        已开票金额
                                    </th>
                                    <th>
                                        已付金额
                                    </th>
                                    <th>
                                        本次所需金额
                                    </th>
                                    <th>
                                        预计付款时间
                                    </th>
                                    <th>
                                        <asp:Button ID="btnAdd" runat="server" Text="增加" CssClass="btn" CausesValidation="false"
                                            OnClick="btnAdd_Click" />
                                    </th>
                                </tr>
                                <asp:Repeater ID="fld_detail_PROC_MARKETPAYREIM_DETAIL" runat="server" OnItemCommand="fld_detail_PROC_MARKETPAYREIM_DETAIL_ItemCommand">
                                    <ItemTemplate>
                                        <tr>
                                            <td class="td-content">
                                                <asp:TextBox ID="fld_FORMID" Text='<%#Eval("FORMID") %>' runat="server" Style="display: none"></asp:TextBox>
                                                <asp:Label ID="select" Text="点击查询" onclick="Tests(this)" runat="server" Width="80%"
                                                    Style="text-decoration: underline; color: Blue; cursor: pointer;"></asp:Label>
                                            </td>
                                            <td class="td-content">
                                                <asp:TextBox ID="fld_CONTARTNO" Text='<%#Eval("CONTARTNO") %>' runat="server" Width="80%"
                                                    CssClass="validate[required]" onfocus="this.blur()" onpaste="return false" oncopy="return false"></asp:TextBox>
                                            </td>
                                            <td class="td-content">
                                                <asp:TextBox ID="fld_SUPPLIER" Text='<%#Eval("SUPPLIER") %>' runat="server" Width="80%"
                                                    CssClass="validate[required]" onfocus="this.blur()" onpaste="return false" oncopy="return false"></asp:TextBox>
                                            </td>
                                            <td class="td-content">
                                                <asp:TextBox ID="fld_CONTENT" Text='<%#Eval("CONTENT") %>' runat="server" Width="80%"></asp:TextBox>
                                            </td>
                                            <td class="td-content">
                                                <asp:TextBox ID="fld_CONTRACTCAPTITAL" Text='<%#Eval("CONTRACTCAPTITAL") %>' money="money"
                                                    runat="server" Width="80%" CssClass="validate[required]" onfocus="this.blur()" onpaste="return false" oncopy="return false"></asp:TextBox>
                                            </td>
                                            <td class="td-content">
                                                <asp:TextBox ID="fld_CONTRACTQTY" Text='<%#Eval("CONTRACTQTY") %>' money="money"
                                                    runat="server" Width="80%" CssClass="validate[required]" onfocus="this.blur()" onpaste="return false" oncopy="return false"></asp:TextBox>
                                            </td>
                                            <td class="td-content">
                                                <asp:TextBox ID="fld_SUPPLIERQTY" Text='<%#Eval("SUPPLIERQTY") %>' money="money"
                                                    runat="server" Width="80%" CssClass="validate[required]" onfocus="this.blur()" onpaste="return false" oncopy="return false"></asp:TextBox>
                                            </td>
                                            <td class="td-content">
                                                <asp:TextBox ID="fld_YKPJE" Text='<%#Eval("YKPJE") %>' money="money" runat="server"
                                                    Width="80%" CssClass="validate[required]" onfocus="this.blur()" onpaste="return false" oncopy="return false"></asp:TextBox>
                                            </td>
                                            <td class="td-content">
                                                <asp:TextBox ID="fld_AMOUNT" Text='<%#Eval("AMOUNT") %>' money="money" runat="server"
                                                    Width="80%" CssClass="validate[required]" onfocus="this.blur()" onpaste="return false" oncopy="return false"></asp:TextBox>
                                            </td>
                                            <td class="td-content">
                                                <asp:TextBox ID="fld_REQUIRED" Text='<%#Eval("REQUIRED") %>' money="money" runat="server"
                                                    Width="80%" CssClass="validate[required]" onkeyup="ChangePay()" onblur="Find(this)"></asp:TextBox>
                                            </td>
                                            <td class="td-content">
                                                <asp:TextBox ID="fld_PAYTIME" Text='<%#Eval("PAYTIME") %>' runat="server" Width="80%"
                                                    OnClick="WdatePicker()" CssClass="validate[required] Wdate"></asp:TextBox>
                                            </td>
                                            <td>
                                                <asp:Button ID="btnDelete" runat="server" Text="删除" CssClass="btn" CommandName="del"
                                                    OnClientClick="deletetS(this);return confirm('确认删除？')" />
                                            </td>
                                        </tr>
                                    </ItemTemplate>
                                </asp:Repeater>
                            </table>
                        </td>
                    </tr>
                </tbody>
                <tbody id="DivContract" style="display: none;" class="table table-condensed table-bordered">
                    <tr>
                        <td class="banner" colspan="4">
                            发票报销类
                        </td>
                    </tr>
                    <tr>
                        <td class="td-label">
                            发票所属公司：<span class="red">*</span>
                        </td>
                        <td class="td-content">
                            <asp:TextBox ID="fld_INVOICECOMPANY" runat="server" CssClass="validate[required]"></asp:TextBox>
                        </td>
                        <td class="td-label">
                            选择中心审批：<span class="red">*</span>
                        </td>
                        <td class="td-content">
                            <asp:DropDownList ID="fld_CENTERINVOICE" runat="server" CssClass="validate[required]">
                                <asp:ListItem Value="">--请选择--</asp:ListItem>
                                <asp:ListItem Value="工程中心">工程中心</asp:ListItem>
                                <asp:ListItem Value="服务中心">服务中心</asp:ListItem>
                                <asp:ListItem Value="咨询中心">咨询中心</asp:ListItem>
                                <asp:ListItem Value="国际服务部">国际服务部</asp:ListItem>
                                <asp:ListItem Value="软件中心">软件中心</asp:ListItem>
                                <asp:ListItem Value="技术中心">技术中心</asp:ListItem>
                            </asp:DropDownList>
                        </td>
                    </tr>
                    <tr>
                        <td class="td-label">
                            发票金额：<span class="red">*</span>
                        </td>
                        <td class="td-content">
                            <asp:TextBox ID="fld_INVOICECAPTITAL" money="money" Text="" runat="server" CssClass="validate[required]"
                                onblur="ChangeInvoice()"></asp:TextBox>
                            <asp:TextBox runat="server" ID="fld_INVOICEUPPER" Style="display: none"></asp:TextBox>
                        </td>
                        <td class="td-label">
                            发票金额大写：
                        </td>
                        <td class="td-content">
                            <asp:Label ID="lbINVOICEUPPER" runat="server" Text=""></asp:Label>
                        </td>
                    </tr>
                    <tr>
                        <td class="td-label">
                            发票信息：
                        </td>
                        <td class="td-content">
                            <asp:TextBox ID="fld_INVOICEINFO" runat="server"></asp:TextBox>
                        </td>
                        <td class="td-label">
                            发票号：<span class="red">*</span>
                        </td>
                        <td class="td-content">
                            <asp:TextBox ID="fld_INVOICENO" runat="server" CssClass="validate[required]"></asp:TextBox>
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>
        <div class="row">
            <attach:attachments id="Attachments1" runat="server"></attach:attachments>
        </div>
        <div class="row">
            <ah:approvalhistory id="ApprovalHistory1" showaction="false" runat="server"></ah:approvalhistory>
        </div>
        <div class="row">
        </div>
    </div>
    <btn:buttonlist id="ButtonList1" runat="server"></btn:buttonlist>
    <div style="display: none;">
    </div>
    </form>
</body>
</html>
